package com.itfenghuang.day14;

public class A03_Cook extends Thread{
    @Override
    public void run() {
        while (true){
            synchronized (A03_Dask.o){
               if (!A03_Dask.flag){
//                   说明没有菜
                   System.out.println("厨师开始做菜");
//                   修改桌子上的状态
                   A03_Dask.flag=true;
//                   叫醒吃货
                   A03_Dask.o.notifyAll();
               }else {
//                   厨子休息
                   try {
                       A03_Dask.o.wait();
                   } catch (InterruptedException e) {
                       e.printStackTrace();
                   }
               }
            }
        }
    }
}
